﻿using System;

namespace QuantBox.XApi
{
    public readonly struct UfxErrorInfo : IEquatable<UfxErrorInfo>
    {
        public readonly int ErrCode;
        public readonly string ErrMsg;

        public UfxErrorInfo(int code, string msg)
        {
            ErrCode = code;
            ErrMsg = msg;
        }

        public static readonly UfxErrorInfo Ok = new UfxErrorInfo(0, "OK");

        public bool Equals(UfxErrorInfo other)
        {
            return ErrCode == other.ErrCode;
        }

        public override bool Equals(object obj)
        {
            return obj is UfxErrorInfo other && Equals(other);
        }

        public override int GetHashCode()
        {
            return ErrCode;
        }

        public static bool operator ==(UfxErrorInfo lhs, UfxErrorInfo rhs)
        {
            return lhs.Equals(rhs);
        }

        public static bool operator !=(UfxErrorInfo lhs, UfxErrorInfo rhs)
        {
            return !(lhs == rhs);
        }
    }
}